package forum.server.domain;

import java.util.Date;

import forum.server.persistence.old.UserType;

/**
 * The class extends Moderator and represents an admin.
 * An admin can do anything a moderator can, in addition to
 * promoting and demoting moderators.
 * @author Alon Furman
 */

public class Admin extends Moderator  {
    /**
     * Default constructor - required for the xml.
     */
    public Admin() {
        super();
    }

    /**
     * Constructor which creates a new admin with the minimal
     * required information: username and password, without personal details.
     * @param username - Admin's username.
     * @param password - Admin's password.
     */
    public Admin(String username, String password) {
        super(username, password);
    }

    /**
     * Constructor used to create a new admin given his personal information.
     * @param username - Admin's username.
     * @param password - Admin's password.
     * @param firstName - Admin's first name.
     * @param lastName - Admin's last name.
     * @param gender - Admin's gender.
     * @param city - Admin's city name.
     * @param birthday - Admin's birthday date.
     */
    public Admin(String username, String password, String firstName,
            String lastName, String email, Gender gender, String city, Date birthday) {
        super(username, password, firstName, lastName, email, gender, city, birthday);
    }


    /**
     * Demotes a moderator to a regular user.
     * @param moderator - The moderator to be demoted.
     * @return - Regular user containing the demoted moderator's details.
     */
    @Override
    public LoggedInUser demoteModerator(Moderator moderator) {
        LoggedInUser tRegUser = new LoggedInUser(moderator);
        return tRegUser;
    }

    /**
     * Promotes a regular user to a moderator in charge of the specified forum.
     * @param user - Regular user to be promoted to moderator.
     * @return The promoted moderator containing the regular user's details.
     */
    @Override
    public Moderator promoteModerator(LoggedInUser user) {
        Moderator tModerator = new Moderator(user);
        return tModerator;
    }
    /**
     * 
     * @return the permission of the user.
     */
    public UserType getPermission(){
    	return UserType.ADMIN;
    }
}
